import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PerformanceSummaryVO, PerformanceSummaryForm, PerformanceSummaryQuery } from '@/api/performance/performanceSummary/types';

/**
 * 查询绩效汇总列表
 * @param query
 * @returns {*}
 */

export const listPerformanceSummary = (query?: PerformanceSummaryQuery): AxiosPromise<PerformanceSummaryVO[]> => {
  return request({
    url: '/performance/performanceSummary/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询绩效汇总详细
 * @param id
 */
export const getPerformanceSummary = (id: string | number): AxiosPromise<PerformanceSummaryVO> => {
  return request({
    url: '/performance/performanceSummary/' + id,
    method: 'get'
  });
};

/**
 * 新增绩效汇总
 * @param data
 */
export const addPerformanceSummary = (data: PerformanceSummaryForm) => {
  return request({
    url: '/performance/performanceSummary',
    method: 'post',
    data: data
  });
};

/**
 * 修改绩效汇总
 * @param data
 */
export const updatePerformanceSummary = (data: PerformanceSummaryForm) => {
  return request({
    url: '/performance/performanceSummary',
    method: 'put',
    data: data
  });
};

/**
 * 删除绩效汇总
 * @param id
 */
export const delPerformanceSummary = (id: string | number | Array<string | number>) => {
  return request({
    url: '/performance/performanceSummary/' + id,
    method: 'delete'
  });
};

/**
 * 同步领星接口
 * @returns {*}
 */
export const calcData = (query?: PerformanceSummaryQuery) => {
  return request({
    url: '/performance/performanceSummary/calcData',
    method: 'get',
    params: query
  });
};
